<include file="Public/min-header"/>
<div class="wrapper">
    <include file="Public/breadcrumb"/>
	<section class="content">
       <div>
       		<div class="col-xs-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">
                    	<i class="fa fa-list"></i>&nbsp;打印机管理
                    </h3>
                </div>
                <div class="panel-body">
<!--                <nav class="navbar navbar-default">	     
			        <div class="collapse navbar-collapse">
			          <form class="navbar-form form-inline" role="search">
			            <div class="form-group pull-right">
				            <a href="{:U('Admin/role_info')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>添加角色</a>
			            </div>		          
			          </form>		
			      	</div>
    			</nav> -->
	            <div class="table-responsive">
		             <table  class="table table-bordered table-striped">
		                <thead>
		                   <tr>
							   <th class="text-center">打印机名（可编辑，必须打印机全名）</th>
			                   <th class="text-center">打印类型</th>
			                   <th class="text-center">宽度</th>
			                   <th class="text-center">高度</th>
			                   <th class="text-center">旋转角度</th>
			                   <th class="text-center">打印机</th>
		                   </tr>
		                </thead>
						<tbody>
						  <tr role="row" align="center">
				                     <td>
<!--										 <input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','biaoqian_print',this)" value="{$printer.biaoqian_print}" class="input-sm" style="width:100%;text-align: center;border: 1px dashed;">-->
										<!--{$printer.biaoqian_print}-->
										<div id="update_biaoqian">
											<select name="" id="">
												<option value=""></option>
											</select>
										</div>
									 </td>
				                     <td>标签打印</td>
									 <td><input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','printb_w',this)" value="{$printer.printb_w}" class="input-sm" style="width:20%;text-align: center;border: 1px dashed;">mm</td>
									 <td><input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','printb_h',this)" value="{$printer.printb_h}" class="input-sm" style="width:20%;text-align: center;border: 1px dashed;">mm</td>
							  <td></td>
							  <td></td>
						  </tr>
								
								<tr role="row" align="center"> <!-- 单据打印 -->
								     <td>
<!--										 <input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','orders_print',this)" value="{$printer.orders_print}" class="input-sm" style="width:100%;text-align: center;border: 1px dashed;">-->
										 <!--{$printer.orders_print}-->
										 <div id="orders_print">
											 <select name="" id="">
												 <option value=""></option>
											 </select>
										 </div>
									 </td>
								     <td>单据打印</td>
									 <td><input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','printd_w',this)" value="{$printer.printd_w}" class="input-sm" style="width:20%;text-align: center;border: 1px dashed;">mm</td>
									 <td><input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','printd_h',this)" value="{$printer.printd_h}" class="input-sm" style="width:20%;text-align: center;border: 1px dashed;">mm</td>
									 <td><input type="text" onchange="update_biaoqian('store','store_id','{$store_id}','angle',this)" value="{$printer.angle}" class="input-sm" style="width:20%;text-align: center;border: 1px dashed;">%</td>
									 <td>
										 <select name="print_type" id="print_type">
											 <option value="1" <if condition="$printer.print_type eq 1">selected</if> >针式打印机</option>
											 <option value="2" <if condition="$printer.print_type eq 2">selected</if>>热敏打印机</option>
										 </select>
									 </td>
								</tr>
		                   </tbody>
		               </table>
		            </div>	 
	              	<div class="row">
	              	    <div class="col-sm-6 text-left"></div>
	                    <div class="col-sm-6 text-right">{$page}</div>		
	              	</div>
	          </div>
	        </div>
       	</div>
      </div>
   </section>
</div>
<script type="text/javascript" src="/Public/js/kd_LodopFuncss.js?v=2.333"></script>
<script>
	window.onload = function() {
		var mybprint = '{$printer.biaoqian_print}';
		var mydprint = '{$printer.orders_print}';
		var arr = printerList();
		var html = '';
		var dhtml = '';
		if(mybprint != ''){
			btitle = mybprint+'(已选打印机)';
		}else{
			btitle = '请选择打印机'
		}
		if(mydprint != ''){
			dtitle = mydprint+'(已选打印机)';
		}else{
			dtitle = '请选择打印机'
		}
		html += '<select name="biaoqian_print" id="biaoqian_print">\n';
		html += '<option value="">'+btitle+'</option>'
		dhtml += '<select name="d_print" id="d_print">\n';
		dhtml += '<option value="">'+dtitle+'</option>'
		for (var i = 0;i<arr.length;i++){
			if(arr[i] == mybprint){
				var selected = 'selected';
			}else{
				var selected = '';
			}
			html += '<option value="'+arr[i]+'" '+selected+'>'+arr[i]+'</option>';
			if(arr[i] == mydprint){
				var selected = 'selected';
			}else{
				var selected = '';
			}
			dhtml += '<option value="'+arr[i]+'" '+selected+'>'+arr[i]+'</option>';
		}
		html +='\t\t\t\t\t\t\t\t\t\t\t</select>';
		dhtml +='\t\t\t\t\t\t\t\t\t\t\t</select>';
		$('#update_biaoqian').html(html);
		$('#orders_print').html(dhtml);


		$('#biaoqian_print').on('change', function() {
			var t = this
			update_biaoqian('store','store_id','{$store_id}','biaoqian_print',t)
		});
		$('#d_print').on('change', function() {
			var t = this
			update_biaoqian('store','store_id','{$store_id}','orders_print',t)
		});


	};
	$(document).ready(function(){
		$('#print_type').change(function(){
			//获取二级分类写入
			$.ajax({
				type: "POST",
				url: "{:U('Store/setPrintType')}",//+tab,
				data: {print_type:$(this).val()},
				dataType: 'json',
				success: function (data) {
					layer.msg('更新完毕')
				},
				error:function(){

				}
			});
		});
	})
function delfun(obj){
	if(confirm('确认删除')){		
		$.ajax({
			type : 'post',
			url : $(obj).attr('data-url'),
			data : {act:'del',role_id:$(obj).attr('data-id')},
			dataType : 'json',
			success : function(data){
				if(data==1){
					$(obj).parent().parent().remove();
				}else{
					layer.alert(data, {icon: 2});   //alert('用户名或密码不能为空');// alert(data);
				}
			}
		})
	}
	return false;
}
</script>  
</body>
</html>